package com.study.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

import com.study.model.jdao.RightsJdao;
import com.study.model.mdao.RightsMdao;
import com.study.model.pojo.Rights;
@Service
public class RightsServices {
	@Autowired
	RightsMdao rmd;
	@Autowired
	RightsJdao jmd;
	
	public void addRights(Rights r){
		r.setRid(rmd.findMaxid(r.getDeptno())==null?(r.getDeptno()+1):rmd.findMaxid(r.getDeptno())+1);
		rmd.addRights(r);
	};
	
	public List<Rights> findAllrightBydt(int deptno){
		return jmd.findAllrightBydt(deptno);
	}
	/**
	 * 查找员工在这个部门没有的权限*/
	public List<Rights> notthisright(int deptno,int eid){
		return jmd.notthisright(deptno, eid);
	}
	/**
	 * 权限名*/
	public String rightname(int deptno,int eid){
		return jmd.rightname(deptno, eid);
		
	};
	public String rightname2(int rid){
		return rmd.findRname(rid);
	}
	/**
	 * 查询员工拥有的权限*/
	public List<Rights> rightnamex(int eid,int deptno){
		return jmd.rightnamex(eid,deptno);
	};
	
	public List<String> rightnamey(int eid,int deptno){
		return jmd.rightnamey(eid, deptno);
	};
	/**
	 * 删除权限*/
	public void delrights(int rid){
		rmd.delrights(rid);
	}
}
